package com.sgj.dao;

import com.sgj.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 沈国纪
 * @date 2021/3/3 16:55
 */
public interface UserMapper {

    @Select("select * from user")
    List<User> getUsers();

    // 方法存在参数，所有的参数必须加上 @Param 注解
    @Select("select * from user where id = #{id}")
    List<User> getUserByID(@Param("id") int id);

    @Insert("insert into user(id,name,pwd) values (#{id},#{name},#{pwd})")
    int addUser(User user);

    @Update("update user set name=#{name},pwd=#{pwd} where id=#{id}")
    int updateUser(User user);

    @Delete("delete from user where id=#{id}")
    int deleteUser(@Param("id") int id);
}
